<?
require_once('config.php');
$current_page = getValue('page','int','GET',1);
$limit_page   = 20;
$start        =   ($current_page -1) * $limit_page; 

$sql = "SELECT * FROM contacts ORDER BY con_date DESC";
$db = new DB();
$list = $db->query($sql);
$count = count($list);

$sql = "SELECT count(con_id) FROM contacts";
$total = $db->single($sql);
$pages = ceil($total/$limit_page);
?>
<?=$css_module?>
<?=$js_module?>
<div class="row-fluid">
   <div class="head">
      <div class="isw-grid"></div>
      <h1>Ý kiến phản hồi</h1>    
      <div class="reload_tab" title="Reload"></div>                              
      <div class="clear"></div>
   </div>                                
   <div class="block-fluid table-sorting">
      <div id="tSortable_wrapper" class="dataTables_wrapper" >
         <table cellpadding="0" cellspacing="0" width="100%" class="table dataTable table-bordered" id="tSortable"  style="width: 100%;">
            <thead>
              <tr>
                  <th class="sorting_disabled"  rowspan="1" colspan="1" style="width: 23px;">
                     <div class="checker">
                        <span>
                           <input type="checkbox" name="checkall" style="opacity: 0;"/>
                        </span>
                     </div>
                  </th>
                  <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="">Xóa</th>
                  <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="">ID</th>
                  <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="">Thời gian</th>
                  <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="">Email</th>
                  <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="">Họ tên</th>
                  <th class="sorting" tabindex="0" rowspan="1" colspan="1" style="">Nội dung</th>
               </tr>
            </thead>
              <?
              if($count > 0){
                  foreach($list as $value){
                  $con_date = date("H:i - d/m/Y",$value['con_date']);
                  ?>
                     <tr class="even">
                        <td class=" sorting_1">
                           <div class="checker">
                              <span>
                                 <input type="checkbox" class="checkbox-row" name="row_to_delete[]" value="<?=$value['con_id']?>" style="opacity: 0;"/>
                              </span>
                           </div>
                        </td>
                        <td class="">
                           <span class="delete-row" onclick="deleteOnlyRow(this)" data-id=<?=$value['con_id']?>  >Xóa</span>
                        </td>
                        <td class=" "><?=$value['con_id']?></td>
                        <td class=" "><?=$con_date?></td>    
                        <td class=" "><?=$value['con_email']?></td>
                        <td class=" "><?=$value['con_full_name']?></td>
                        <td class=" "><?=$value['con_content']?></td>     
                                                                  
                    </tr>
                  <?}?>
                  
                
              <?}?>
          </table>
         </div>
      <div class="clear"></div>
      <div class="mult_submit">
         <span>Với những dòng đã chọn: </span>  <span class="delete-row mult-delete">Xóa</span>   
      </div>
      <div class="pull-left showing"><?=($current_page -1) * $limit_page + 1 ?> - <?=($current_page -1) * $limit_page + $count?> of <?=$total?></div>
      <div class="paging pull-right">
         <?php $pagination = pagination($current_page,$pages,'list.php?page=%d') ?>
         <ul>
         <?php foreach ($pagination as $link): ?>
           <li><?php echo $link ?></li>
         <?php endforeach ?>
         </ul>
      </div>
   </div>
</div>
